package com.zhiqianbao.utils;

import android.app.Activity;
import android.content.Intent;

import com.zhiqianbao.activity.FirstTimeConfirmInfoProgressThreeZx;
import com.zhiqianbao.activity.ProcessActivity;

/**
 * Created by liang on 2015/12/26.
 */
public class CheckUtils {
    public final static Class three = FirstTimeConfirmInfoProgressThreeZx.class;
    /**
     *
     * @param activity
     * @param nextActivity
     */
    public static void checkUserState(Activity activity, Class nextActivity) {
        //用户没有登录，跳转到登录页面
        if (Constants.LOGIN_USER == null) {
//            Intent loginIntent = new Intent(activity, LoginActivity.class);
//            activity.startActivity(loginIntent);
            return;
        }
        //用户处于登录状态，判断用户信息完善状态
        String userInfoState = Constants.LOGIN_USER.getAuditState();
        //用户刚刚注册完成，跳转到第一部完善个人信息页面
        if (Constants.USER_STATE_REGIST_INFO.equals(userInfoState)) {
            Intent oneInfoIntent = new Intent(activity, ProcessActivity.class);
            activity.startActivity(oneInfoIntent);
            return;
            //第一步个人信息完成，跳转到第二步
        } else if (Constants.USER_STATE_FIRST_INFO.equals(userInfoState)) {
            Intent twoInfoIntent = new Intent(activity, ProcessActivity.class);
            activity.startActivity(twoInfoIntent);
            return;
            //第二步个人信息完成，跳转到第三步
        } else if (Constants.USER_STATE_SECOND_INFO.equals(userInfoState)) {
            Intent threeInfoIntent = new Intent(activity, ProcessActivity.class);
            activity.startActivity(threeInfoIntent);
            return;
            //所有个人信息完成，跳转到下一个activity
        } else {
            Intent nextIntent = new Intent(activity, nextActivity);
            activity.startActivity(nextIntent);
//        }
        }
    }

    /**
     *
     * @param activity
     * @param intent
     */
    public static void checkUserState(Activity activity, Intent intent) {
        //用户没有登录，跳转到登录页面
        if(Constants.LOGIN_USER == null) {
            Intent loginIntent = new Intent(activity,
                    WorthPurseUtil.getZhiddActivity().getClass());
            activity.startActivity(loginIntent);
            activity.finish();
            return;
        }
        //用户处于登录状态，判断用户信息完善状态
        String userInfoState = Constants.LOGIN_USER.getAuditState();
        //用户刚刚注册完成，跳转到第一部完善个人信息页面
        if(Constants.USER_STATE_REGIST_INFO.equals(userInfoState)) {
            Intent oneInfoIntent = new Intent(activity, ProcessActivity.class);
            activity.startActivity(oneInfoIntent);
            return;
            //第一步个人信息完成，跳转到第二步
        } else if (Constants.USER_STATE_FIRST_INFO.equals(userInfoState)) {
            Intent twoInfoIntent = new Intent(activity, ProcessActivity.class);
            activity.startActivity(twoInfoIntent);
            return;
            //第二步个人信息完成，跳转到第三步
        } else if (Constants.USER_STATE_SECOND_INFO.equals(userInfoState)) {
            Intent threeInfoIntent = new Intent(activity, ProcessActivity.class);
            activity.startActivity(threeInfoIntent);
            return;
            //所有个人信息完成，跳转到下一个activity
        } else {
            activity.startActivity(intent);
        }
    }

    /**
     * 只判断 通过后不做任何操作
     * @param activity
     */
    public static boolean checkUserState(Activity activity) {
        //用户没有登录，跳转到登录页面
        if(Constants.LOGIN_USER == null) {
            Intent loginIntent = new Intent(activity,
                    WorthPurseUtil.getZhiddActivity().getClass());
            activity.startActivity(loginIntent);
            activity.finish();
            return true;
        }
        //用户处于登录状态，判断用户信息完善状态
        String userInfoState = Constants.LOGIN_USER.getAuditState();
        //用户刚刚注册完成，跳转到第一部完善个人信息页面
        if(Constants.USER_STATE_REGIST_INFO.equals(userInfoState)) {
//            Intent intent = new Intent(activity, UpdateJobActivity.class);
//            activity.startActivityForResult(new Intent(activity,ProcessActivity.class),9);
//            Intent oneInfoIntent = new Intent(activity, ProcessActivity.class);
//            activity.startActivity(oneInfoIntent);
            return true;
            //第一步个人信息完成，跳转到第二步
        } else if (Constants.USER_STATE_FIRST_INFO.equals(userInfoState)) {
            Intent twoInfoIntent = new Intent(activity, ProcessActivity.class);
            activity.startActivity(twoInfoIntent);
            return true;
            //第二步个人信息完成，跳转到第三步
        } else if (Constants.USER_STATE_SECOND_INFO.equals(userInfoState)) {
            Intent threeInfoIntent = new Intent(activity, ProcessActivity.class);
            activity.startActivity(threeInfoIntent);
            return true;
        }
        return false;
    }
    public static boolean checkUserState1(Activity activity) {
        //用户没有登录，跳转到登录页面
        if(Constants.LOGIN_USER == null) {
            Intent loginIntent = new Intent(activity,
                WorthPurseUtil.getZhiddActivity().getClass());
            activity.startActivity(loginIntent);
            activity.finish();
            return true;
        }
        //用户处于登录状态，判断用户信息完善状态
        String userInfoState = Constants.LOGIN_USER.getAuditState();
        //用户刚刚注册完成，跳转到第一部完善个人信息页面
        if(Constants.USER_STATE_REGIST_INFO.equals(userInfoState)) {
//            Intent intent = new Intent(activity, UpdateJobActivity.class);
//            activity.startActivityForResult(new Intent(activity,ProcessActivity.class),9);
            Intent oneInfoIntent = new Intent(activity, ProcessActivity.class);
            activity.startActivity(oneInfoIntent);
            return true;
            //第一步个人信息完成，跳转到第二步
        } else if (Constants.USER_STATE_FIRST_INFO.equals(userInfoState)) {
            Intent twoInfoIntent = new Intent(activity, ProcessActivity.class);
            activity.startActivity(twoInfoIntent);
            return true;
            //第二步个人信息完成，跳转到第三步
        } else if (Constants.USER_STATE_SECOND_INFO.equals(userInfoState)) {
            Intent threeInfoIntent = new Intent(activity, ProcessActivity.class);
            activity.startActivity(threeInfoIntent);
            return true;
        }
        return false;
    }
    /**
     * 只判断 通过后不做任何操作
     */
    public static boolean checkUserState() {
        //用户没有登录，跳转到登录页面
        if(Constants.LOGIN_USER == null) {
            return true;
        }
        //用户处于登录状态，判断用户信息完善状态
        String userInfoState = Constants.LOGIN_USER.getAuditState();
        //用户刚刚注册完成，跳转到第一部完善个人信息页面
        if(Constants.USER_STATE_REGIST_INFO.equals(userInfoState)) {
            return true;
            //第一步个人信息完成，跳转到第二步
        } else if (Constants.USER_STATE_FIRST_INFO.equals(userInfoState)) {
            return true;
            //第二步个人信息完成，跳转到第三步
        } else if (Constants.USER_STATE_SECOND_INFO.equals(userInfoState)) {
            return true;
        }
        return false;
    }
}
